package com.lch.sort;

/**
 * @author 刘晨辉
 * @date 2021/8/23 12:59 下午
 */
public class BubbleSort {

    public static void main(String[] args) {
        int[] a = new int[]{43, 5, 7, 3, 7, 3};

        for (int i = 0; i < a.length; i++) {
            boolean flag = false;
            for (int j = 0; j < a.length - i - 1; j++) {
                if (a[j] > a[j + 1]) {
                    int temp = a[j];
                    a[j] = a[j+1];
                    a[j+1] = temp;
                    flag = true;
                }
            }
            if (!flag) {
                break;
            }
        }

        for (int i = 0; i < a.length; i++) {
            System.out.printf(a[i] + ",");
        }
    }
}
